/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.liwei.nio.mina;

import java.io.DataOutputStream;
import java.net.Socket;

/**
*
* @author lidian
* @version $Id: MyProtocalClient.java, v 0.1 2011-1-27 上午10:13:29 lidian Exp $
*/
public class MyProtocalClient {

    public static void main(String[] args) {
        try {
            Socket socket = new Socket("127.0.0.1", 2500);
            DataOutputStream out = new DataOutputStream(socket.getOutputStream());
            for (int i = 0; i < 1000; i++) {
                MyProtocalPack pack = new MyProtocalPack((byte) i, i + "测试MyProtocalaaaaaaaaaaaaaa");
                out.writeInt(pack.getLength());
                out.write(pack.getFlag());
                out.write(pack.getContent().getBytes());
                out.flush();
                System.out.println(i + " sended");
            }
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}